package net.lulihu.pangolin.headless.client.handler;

import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import net.lulihu.pangolin.headless.common.container.annotation.Component;
import net.lulihu.pangolin.headless.common.protocol.ProtocolMessage;
import net.lulihu.pangolin.headless.common.protocol.ProtocolMessageType;
import net.lulihu.pangolin.headless.common.protocol.handler.RegistrationMessageTypeHandlerComponent;
import net.lulihu.pangolin.headless.common.util.ChannelDataTransferKit;

/**
 * 服务器数据转移消息处理程序
 */
@Slf4j
@Component
public class ServerDataTransferMessageHandler implements RegistrationMessageTypeHandlerComponent {

    @Override
    public byte messageType() {
        return ProtocolMessageType.TYPE_DATA_TRANSFER;
    }

    @Override
    public void handle(ChannelHandlerContext context, ProtocolMessage message) {
        if (log.isDebugEnabled()) log.debug("收到服务器数据转移消息");

        ChannelDataTransferKit.transferData(context, message);
    }

}
